#ifndef __MENU_H
#define __MENU_H
#include "stm32f10x.h"
#include "sys.h"
#include "rtc.h"

#define MAIN_INDEX   0

#define SET_TIME_INDEX  	(MAIN_INDEX + 1)
#define SET_DATE_INDEX		(SET_TIME_INDEX + 1)
#define SET_ALAR_INDEX		(SET_DATE_INDEX + 1)
#define SET_PLUS_INDEX		(SET_ALAR_INDEX + 1)
#define SET_PWM_INDEX		(SET_PLUS_INDEX + 1)
#define SET_EXIT_INDEX		(SET_PWM_INDEX  + 1)


#define TIME_HOUR_INDEX		(SET_EXIT_INDEX + 1)
#define TIME_MIN_INDEX		(TIME_HOUR_INDEX + 1)
#define TIME_SEC_INDEX		(TIME_MIN_INDEX + 1)
#define TIME_SAVE_INDEX		(TIME_SEC_INDEX + 1)
#define TIME_EXIT_INDEX		(TIME_SAVE_INDEX + 1)

#define DATE_YEAR_INDEX		(TIME_EXIT_INDEX + 1)
#define DATE_MONTH_INDEX	(DATE_YEAR_INDEX + 1)
#define DATE_DAY_INDEX		(DATE_MONTH_INDEX + 1)
#define DATE_SAVE_INDEX		(DATE_DAY_INDEX + 1)
#define DATE_EXIT_INDEX		(DATE_SAVE_INDEX + 1)


#define ALARM_HOUR_INDEX	(DATE_EXIT_INDEX + 1)	
#define ALARM_MIN_INDEX		(ALARM_HOUR_INDEX +1)
#define ALARM_SEC_INDEX		(ALARM_MIN_INDEX + 1)
#define ALARM_SAVE_INDEX	(ALARM_SEC_INDEX + 1)
#define ALARM_EXIT_INDEX	(ALARM_SAVE_INDEX + 1)

#define PLUS_WIDTH_INDEX	(ALARM_EXIT_INDEX + 1)
#define PLUS_POLAR_INDEX	(PLUS_WIDTH_INDEX + 1)  /* 极性 */
#define PLUS_TRIG_INDEX     (PLUS_POLAR_INDEX + 1)
#define PLUS_EXIT_INDEX     (PLUS_TRIG_INDEX  + 1)

#define PWM_CYCLE_INDEX     (PLUS_EXIT_INDEX + 1)
#define PWM_DUTY_INDEX      (PWM_CYCLE_INDEX + 1)
#define PWM_EXIT_INDEX      (PWM_DUTY_INDEX + 1)



typedef struct MenuTable{
	u8 current;   /* 当前索引号       */
	u8 select;    /* 按键 “选择” */
	u8 add;       /* 按键 “加”      */
	u8 sub;       /* 按键 “减”      */
	u8 enter;     /* 按键 “确认” */
	void (*current_operation)(void *arg);
}T_MenuTable, *PT_MenuTable;



extern T_MenuTable g_taMenuTable[];
extern tTime g_tTimeTmp;
extern tTime g_tAlarmTmp;

u8 isClearOLED(u8 indexOld, u8 indexNew);


#endif /* __MENU_H */

